const shogun = {
    name: "Yoshiaki",
    clan: "Ashikaga",
    get fullTitle() {
        return this.name + " " + this.clan;
    },
    set fullTitle(value) {
        const segments = value.split(" ");
        this.name = segments[0];
        this.clan = segments[1];
    }
};

const emperor = { name: "Komei"};
const representative = new Proxy(emperor, {
    get: (target, key) => {
        console.log("Reading " + key + " through a proxy");
        return key in target ? target[key] : "Don't bother the emperor!"
    },
    set: (target, key, value) => {
        console.log("Writing " + key + " through a proxy");
        target[key] =  value;
    }
});
console.log(emperor.name);
console.log(representative.name)
representative.name = 'guojing'
console.log(representative.name)